<template>
  <a-card :bordered="false" class="webCard" style="    height: calc(100vh - 66px);">

    <!-- 查询区域 -->
    <!-- <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="关键字">
              <a-input placeholder="请输入统一信用代码、简称、投资机构等" v-model="queryParam.key"></a-input>
            </a-form-item>
          </a-col>
        
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div> -->

    <!-- 操作按钮区域 -->
    <!-- <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-button type="primary" icon="download" @click="showDownloadSet = true">导出设置</a-button>
      <a-button type="primary" icon="import" @click="handleImportExcelPy">服务拉取</a-button>
    </div> -->
    <div v-if="showDownloadSet && !showCompanyDetail">
      <div class="configRow clearfix">
        <label>搜索：</label>
        <div class="row-data">
          <a-input style="width: 260px" placeholder="请输入统一信用代码、简称、关键词" v-model="queryParam.key"></a-input>
        </div>
      </div>
      <div class="configRow clearfix">
        <label>所有筛选：</label>
        <div class="row-data">
          <a-tag color="blue" closable @close="cancelSelect(item.value)" v-for="(item, index) in chineseSearchList" class="cursor-pointer" :key="index">
            {{item.label}}
          </a-tag>
          <a style="margin-left: 10px" v-if="chineseSearchList.length" @click="searchResetSelf(),getSearchChinese()">清除筛选</a>
        </div>
      </div>
      <div class="configRow clearfix">
        <label>省份地区：</label>
        <div class="row-data">
          <a-tag :class="areaType == 'province' ? 'blue': 'default'" @click="areaType = 'province'" class="cursor-pointer">
            省份
          </a-tag>
          <span style="margin-right: 8px">|</span>
          <a-tag :class="areaType == 'city' ? 'blue': 'default'" @click="areaType = 'city'" class="cursor-pointer">
            城市
          </a-tag>
          <span style="margin-right: 8px">|</span>
          <a-tag :class="areaType == 'district' ? 'blue': 'default'" @click="areaType = 'district'" class="cursor-pointer">
            区县
          </a-tag>
        </div>
        <div class="row-data specialBox" v-if="areaType == 'province'">
          <a-tag :class="!exportParam.provinceId ? 'blue': 'default'" @click="setProvince(''),getSearchChinese(exportParam)" class="cursor-pointer">
            不限
          </a-tag>
          <a-tag class="cursor-pointer" :class="exportParam.provinceId === item.RegionId ? 'blue': 'default'" v-for="(item,index) in provinceData" @click="setProvince(item.RegionId),getSearchChinese(exportParam)" :key="index">
            {{item.RegionName}}
          </a-tag>
        </div>

        <div class="row-data specialBox" v-if="areaType == 'city'">
          <a-tag :class="!exportParam.cityId ? 'blue': 'default'" @click="setCity(''),getSearchChinese(exportParam)" class="cursor-pointer">
            不限
          </a-tag>
          <a-tag class="cursor-pointer" :class="exportParam.cityId === item.RegionId ? 'blue': 'default'" v-for="(item,index) in cityData" @click="setCity(item.RegionId),getSearchChinese(exportParam)" :key="index">
            {{item.RegionName}}
          </a-tag>
        </div>

        <div class="row-data specialBox" v-if="areaType == 'district'">
          <a-tag :class="!exportParam.districtId ? 'blue': 'default'" @click="setDistrict(''),getSearchChinese(exportParam)" class="cursor-pointer">
            不限
          </a-tag>
          <a-tag class="cursor-pointer" :class="exportParam.districtId === item.RegionId ? 'blue': 'default'" v-for="(item,index) in districtData" @click="setDistrict(item.RegionId),getSearchChinese(exportParam)" :key="index">
            {{item.RegionName}}
          </a-tag>
        </div>
      </div>
      <!-- <div class="configRow clearfix">
        <label>城市：</label>
        <div class="row-data">
          <a-tag :color="!exportParam.cityId ? 'blue': null" @click="setProvince('')" class="cursor-pointer">
            不限
          </a-tag>
          <a-tag class="cursor-pointer" :color="exportParam.cityId === item.RegionId ? 'blue': null" v-for="(item,index) in cityData" @click="setCity(item.RegionId)" :key="index">
            {{item.RegionName}}
          </a-tag>
        </div>
      </div>
      <div class="configRow clearfix">
        <label>地区：</label>
        <div class="row-data">
          <a-tag :color="!exportParam.districtId ? 'blue': null" @click="setProvince('')" class="cursor-pointer">
            不限
          </a-tag>
          <a-tag class="cursor-pointer" :color="exportParam.districtId === item.RegionId ? 'blue': null" v-for="(item,index) in districtData" @click="setDistrict(item.RegionId)" :key="index">
            {{item.RegionName}}
          </a-tag>
        </div>
      </div> -->
      <div class="configRow clearfix">
        <label>开发区：</label>
        <div class="row-data">
          <a-tag :color="!exportParam.SubParkId ? 'blue': null" @click="setSubPark(''),getSearchChinese(exportParam)" class="cursor-pointer">
            不限
          </a-tag>
          <a-tag class="cursor-pointer" :color="exportParam.SubParkId === item.BaseHighteckParkId ? 'blue': null" v-for="(item,index) in subParkData" @click="setSubPark(item.BaseHighteckParkId),getSearchChinese(exportParam)" :key="index">
            {{item.ParkName}}
          </a-tag>
        </div>
      </div>
      <div class="configRow clearfix">
        <label>融资时间：</label>
        <div class="row-data">
          <a-tag :color="!exportParam.timeLength ? 'blue': null" @click="setTimeLength(''),getSearchChinese(exportParam)" class="cursor-pointer">
            不限
          </a-tag>
          <a-tag class="cursor-pointer" :color="exportParam.timeLength === item.RegionId ? 'blue': null" v-for="(item,index) in refinanceDateData" @click="setTimeLength(item.RegionId),getSearchChinese(exportParam)" :key="index">
            {{item.RegionName}}
          </a-tag>
          <span style="margin:0px 10px; color: #178DCC;">自定义时间</span>
          <a-range-picker
            v-model="exportParam.selfTime"
            @change="setSelfTime"
            size="small"
            class="webTimePicker"
            :show-time="{
              hideDisabledOptions: true,
              defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
            }"
            format="YYYY-MM-DD"
          />
        </div>
      </div>
      <div class="configRow clearfix">
        <label>一级行业：</label>
        <div class="row-data">
          <a-tag :color="!exportParam.primaryIndustryId ? 'blue': null" @click="setPrimaryIndustry(''),getSearchChinese(exportParam)" class="cursor-pointer">
            不限
          </a-tag>
          <a-tag class="cursor-pointer" :color="exportParam.primaryIndustryId === item.BaseIndustryId ? 'blue': null" v-for="(item,index) in industryData" @click="setPrimaryIndustry(item.BaseIndustryId),getSearchChinese(exportParam)" :key="index">
            {{item.Industry}}
          </a-tag>
        </div>
      </div>
      <div class="configRow clearfix">
        <label>二级行业：</label>
        <div class="row-data">
          <a-tag :color="!exportParam.subIndustryId ? 'blue': null" @click="setSubIndustry(''),getSearchChinese(exportParam)" class="cursor-pointer">
            不限
          </a-tag>
          <a-tag class="cursor-pointer" :color="exportParam.subIndustryId === item.BaseIndustryId ? 'blue': null" v-for="(item,index) in secIndustryData" @click="setSubIndustry(item.BaseIndustryId),getSearchChinese(exportParam)" :key="index">
            {{item.Industry}}
          </a-tag>
        </div>
      </div>
      <!-- <div class="configRow clearfix">
        <label>三级行业：</label>
        <div class="row-data">
          <a-tag :color="!exportParam.thirdIndustryId ? 'blue': null" @click="setThirdIndustry('')" class="cursor-pointer">
            不限
          </a-tag>
          <a-tag class="cursor-pointer" :color="exportParam.thirdIndustryId === item.BaseIndustryId ? 'blue': null" v-for="(item,index) in thirdIndustryData" @click="setThirdIndustry(item.BaseIndustryId)" :key="index">
            {{item.Industry}}
          </a-tag>
        </div>
      </div> -->
      <div class="configRow clearfix">
        <label>融资轮次：</label>
        <div class="row-data">
          <!-- <a-checkbox-group @change="setRound" v-model="exportParam.refinanceRoundId">
            <a-row>
              <a-col :span="3" v-for="(item,index) in refinanceRoundData" :key="index">
                <a-checkbox :value="item.BaseInfoId">
                  {{item.Value}}
                </a-checkbox>
              </a-col>
            </a-row>
          </a-checkbox-group> -->
          <a-tag :color="!exportParam.refinanceRoundId || !exportParam.refinanceRoundId.length ? 'blue': null" @click="setRoundClear(),getSearchChinese(exportParam)" class="cursor-pointer">
            不限
          </a-tag>
          <a-tag class="cursor-pointer" :color="exportParam.refinanceRoundId && exportParam.refinanceRoundId.includes(item.BaseInfoId) ? 'blue': null" v-for="(item,index) in refinanceRoundData" @click="setRound(item.BaseInfoId),getSearchChinese(exportParam)" :key="index">
            {{item.Value}}
          </a-tag>
        </div>
      </div>
      <div class="configRow clearfix">
        <label>产业园区：</label>
        <div class="row-data">
          <a-select style="min-width: 250px" placeholder="请选择产业区域" v-model="exportParam.IndustrialParkId" @change="getSearchChinese(exportParam)">
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseIndustrialParkId" v-for="(item,index) in IndusParkList">{{item.IndustrialParkName}}</a-select-option>
          </a-select>
        </div>
      </div>
      <div class="configRow clearfix">
        <label>资质标签：</label>
        <div class="row-data">
          <a-tag :color="!exportParam.QualificationTag ? 'blue': null" @click="setQuality(''),getSearchChinese(exportParam)" class="cursor-pointer">
            不限
          </a-tag>
          <a-tag class="cursor-pointer" :color="exportParam.QualificationTag === item.Value ? 'blue': null" v-for="(item,index) in qualificationTagData" @click="setQuality(item.Value),getSearchChinese(exportParam)" :key="index">
            {{item.Value}}
          </a-tag>
        </div>
      </div>
      <hr />
      <div class="configRow clearfix" style="text-align:right">
        <a-button @click="searchResetSelf" icon="reload" style="margin-right: 8px">重置</a-button>
        <a-button type="primary" @click="searchQuery">查询</a-button>
      </div>
    </div>
    <!-- table区域-begin -->
    <div v-if="!showCompanyDetail">
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;height:40px;">
        <div style="float: left;width: 383px;">
          <span>
            列表（共<b style="color:#1890FF;margin:0px 3px">{{ipagination.total}}</b>条数据）
          </span>
          <a-button v-if="userMessage.userName" type="primary" size="small" @click="handleExportXlsSelf('融资历程', exportParam)">导出数据</a-button>
        </div>
      </div>
      <div style="margin-bottom: 10px">
        <setColumnFieldsWeb @chooseFields="chooseFields" :columns="columnsCopy"></setColumnFieldsWeb>
      </div>
      <a-table
        ref="table"
        size="middle"
        
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <span slot="company" slot-scope="text, record">
          <div style="position: relative;padding-left: 50px;text-align: left">
            <img v-if="record.Company_CompanyLogo" style="width:40px;height: 40px;position: absolute;left:0px;top:0px" :src="'https://link.zhangtongshe.com'+JSON.parse(record.Company_CompanyLogo).downloadUrl">
            <img v-else style="width:40px;height: 40px;position: absolute;left:0px;top:0px" :src="require('../../assets/default_company.png')">
            <div>
              <p style="margin-bottom: 0px;font-weight: 600;font-size:16px">{{text}}</p>
              <p style="margin-bottom: 0px;">{{record.Company_CompanyName}}</p>
            </div>
          </div>
        </span>
        <span slot="position" slot-scope="text, record">
          <span class="">{{record.Company_Province_RegionName}}</span>
          <span v-if="record.Company_City_RegionName" style="margin:0px 5px">></span>
          <span class="" v-if="record.Company_City_RegionName">{{record.Company_City_RegionName}}</span>
          <span v-if="record.Company_District_RegionName" style="margin:0px 5px">></span>
          <span class="" v-if="record.Company_District_RegionName">{{record.Company_District_RegionName}}</span>
        </span>
        <span slot="bread" slot-scope="text, record">
          <span class="tag">{{text}}</span>
          <span v-if="record.Company_Industry_Industry" style="margin:0px 5px">></span>
          <span class="tag" v-if="record.Company_Industry_Industry">{{record.Company_Industry_Industry}}</span>
          <span v-if="record.Company_SubIndustry && isNaN(record.Company_SubIndustry)" style="margin:0px 5px">></span>
          <span class="tag" v-if="record.Company_SubIndustry && isNaN(record.Company_SubIndustry)">{{record.Company_SubIndustry}}</span>
        </span>
        <span slot="tag" slot-scope="text, record">
          <template v-if="text">
            <span class="tagSpan" style="margin-top:5px;color: #ffffff" v-for="(item,index) in text.split(',')">{{item}}</span>
          </template>
        </span>
        <span slot="tagJSON" slot-scope="text, record">
          <template v-if="text && text !== '[]'">
            <!-- {{text}} -->
            <span class="tagSpan" style="margin-top:5px;color: #ffffff">{{text}}</span>
            <!-- <span class="tagSpan" style="margin-top:5px;color: #ffffff" v-for="(item,index) in JSON.parse(text)">{{item}}</span> -->
          </template>
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="handleToCompany(record)">详情</a>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <div v-if="showCompanyDetail" style="background-color: #ffffff;padding-top:10px;">
      <div>
        <!-- <a-button type="primary" style="margin-left:10px" @click="showCompanyDetail = false">
          
        </a-button> -->
        <span style="margin-left:10px;cursor: pointer;color: #1890FF" @click="showCompanyDetail = false"><a-icon type="left" />返回</span>
        
      </div>
      <companyListDetail :companyId="companyId" ref="company"></companyListDetail>
    </div>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  // import CompanyRefinanceModal from './modules/CompanyRefinanceModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import setColumnFieldsWeb from '@/components/setColumnsFieldsWeb'
  import moment from 'moment';
  import axios from "axios"
  import companyListDetail from '../companyListDetail'
  export default {
    name: "CompanyRefinanceList",
    mixins:[JeecgListMixin],
    components: {
        setColumnFieldsWeb,companyListDetail
    },
    data () {
      return {
        showCompanyDetail: false,
        companyId: '',
        description: '融资历程表页面',
        showDownloadSet: true,
        areaType: 'province',
        subParkData: [],
        IndusParkList: [],
        industryTagData: [],
        ipagination:{
            current: 1,
            pageSize: 10,
            pageSizeOptions: ['10', '20', '30'],
            showTotal: (total, range) => {
                return range[0] + "-" + range[1] + " 共" + total + "条"
            },
            showQuickJumper: true,
            showSizeChanger: false,
            total: 0
        },
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: 'sortIndex',
            key:'rowIndex',
            width:60,
            align:"left",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
           },
		   // {
     //        title: '统一信用代码',
     //        align:"left",
     //        dataIndex: 'Company_CompanyCode'
     //       },
          {
            title: '公司代码',
            align:"left",
            dataIndex: 'Company_CompanyCode',
            isKey:true
           },
          {
            title: '公司',
            align:"left",
            width: 300,
            dataIndex: 'Company_CompanyAbbr',
            scopedSlots: { customRender: 'company' },
            isKey:true
           },
           // {
           //  title: '公司全称',
           //  align:"left",
           //  dataIndex: 'Company_CompanyName',
           //  isKey:true
           // },
           {
            title: '一句话简介',
            align:"left",
            dataIndex: 'Company_CompanyBrief',
           },
           {
            title: '公司标签',
            align:"left",
            dataIndex: 'Company_IndustryTag',
            scopedSlots: { customRender: 'tag' },           },
           {
            title: '行业分类',
            align:"left",
            scopedSlots: { customRender: 'bread' },
            dataIndex: 'Company_PrimaryIndustry_Industry'
           },
           // {
           //  title: '二级行业',
           //  align:"left",
           //  dataIndex: 'Company_Industry_Industry'
           // },
           // {
           //  title: '三级行业',
           //  align:"left",
           //  dataIndex: 'Company_SubIndustry',
           // },
           
           
           {
            title: '融资时间',
            align:"left",
            dataIndex: 'RefinanceDate',
            customRender:function (t,r,index) {
              return t?t.split(' ')[0]:'';
            }
           },
           {
            title: '融资轮次',
            align:"left",
            dataIndex: 'RefinanceRound_Value'
           },
           {
            title: '融资金额',
            align:"left",
            dataIndex: 'RefinanceAmt'
           },
           {
            title: '真实融资',
            align:"left",
            dataIndex: 'RefinanceTrueAmt',
            customRender:function (t,r,index) {
              return t?t+'万'+r.CurrencyType_Value:'-';
            }
           },
       {
            title: '最新估值',
            align:"left",
            dataIndex: 'ValuationAmt',
            customRender:function (t,r,index) {
              return t?t:'-';
            }
           },
		   // {
     //        title: '融资币种',
     //        align:"left",
     //        dataIndex: 'CurrencyType_Value'
     //       },
		   
		   
		   
		      {
            title: '投资机构',
            align:"left",
            dataIndex: 'Investors',
            width: 250,
            scopedSlots: { customRender: 'tag' },
           },
           {
            title: '已对外公布',
            align:"left",
            dataIndex: 'IsDisclose',
            customRender:function (t,r,index) {
              return t == 1 ? '是' : t == 0 ? '否' : '';
            }
           },
           {
            title: '有股东变更',
            align:"left",
            dataIndex: 'IsShareholderChanged',
            customRender:function (t,r,index) {
              return t == 1 ? '是' : t == 0 ? '否' : '';
            }
           },
           {
            title: '有注册资本变更',
            align:"left",
            dataIndex: 'IsRegisteredAmtChanged',
            customRender:function (t,r,index) {
              return t == 1 ? '是' : t == 0 ? '否' : '';
            }
           },
           {
            title: '省份地区',
            align:"left",
            dataIndex: 'position',
            scopedSlots: { customRender: 'position' },
           },
           {
            title: '开发区',
            align:"left",
            dataIndex: 'Company_SubPark_ParkName'
           },
           {
            title: '产业园区',
            align:"left",
            dataIndex: 'Company_IndustrialPark_ParkName'
           },
           {
            title: '资质标签',
            align:"left",
            dataIndex: 'Company_QualificationTag',
            scopedSlots: { customRender: 'tagJSON' },
           },
           {
            title: '成立日期',
            align:"left",
            dataIndex: 'Company_RegisteredDate',
            customRender:function (t,r,index) {
              return t?t.split(' ')[0]:'';
            }
           },
           {
            title: '注册地址',
            align:"left",
            dataIndex: 'Company_RegisteredAddress'
           },
		   // {
     //        title: '最近更新人',
     //        align:"left",
     //        dataIndex: 'updateby'
     //       },
		   // {
     //        title: '最近更新日期',
     //        align:"left",
     //        dataIndex: 'Ts'
     //       },
		      // {
        //     title: '最近更新人',
        //     align:"left",
        //     dataIndex: 'UpdateBy_Name',
        //     isKey:true
        //    },
          {
            title: '最近更新日期',
            align:"left",
            dataIndex: 'Ts',
            customRender:function (t,r,index) {
              return t?new Date(parseInt(t)).toLocaleDateString().replace('/','-').replace('/','-'):'';
            }
           },
          {
            title: '操作',
            dataIndex: '',
            width: 60,
            align:"left",
            scopedSlots: { customRender: 'action' },
          }
        ],
        exportParam: {
          provinceId: '',
          cityId: '',
          districtId: '',
          timeLength: '',
          selfTime: null,
          refinanceRoundId: null,
          primaryIndustryId: '',
          subIndustryId: '',
          thirdIndustryId: ''
        },
        provinceData: [],
        cityData: [],
        districtData: [],
        refinanceDateData:[{
          RegionId: 1,
          RegionName: "近1天"
        },{
          RegionId: 7,
          RegionName: "近7天"
        },{
          RegionId: 30,
          RegionName: "近1月"
        },{
          RegionId: 90,
          RegionName: "近3月"
        },{
          RegionId: 180,
          RegionName: "近半年"
        },{
          RegionId: 360,
          RegionName: "近1年"
        }],
        refinanceRoundData:[],
        industryData:[],
        secIndustryData: [],
        thirdIndustryData: [],
        modalData: null,
        showModal: false,
        qualificationTagData:[],
        chineseSearchList: [],
        userMessage: {},
		url: {
          list: "/companyRefinance/queryRows",
          delete: "/companyRefinance/delete",
          deleteBatch: "/robot/companyRefinance/deleteBatch",
          exportXlsUrl: "robot/companyRefinance/exportXls",
          importExcelUrl: "companyRefinance/import/excel",
          exportXlsUrl: '/companyRefinance/queryRows/excel',
          baseList:"/baseInfo/queryRows",
       },
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
    importExcelUrlPy: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
    // chineseSearchList: function(){
    //   let params = this.exportParam
    //   let chineseSearchList = []
    //     console.log('aaaa', params)
    //     let obj = null
    //     let json = {}
    //     if (params.provinceId) {
    //       json = {
    //         label: '省份:',
    //         value: 'provinceId'
    //       }
    //       obj = this.provinceData.find((e) => { return e.RegionId === params.provinceId})
    //       if (obj) {
    //         json.label += obj.RegionName
    //       }
    //       chineseSearchList.push(json)
    //     }
    //     if (params.cityId) {
    //       json = {
    //         label: '城市:',
    //         value: 'cityId'
    //       }
    //       obj = this.cityData.find((e) => { return e.RegionId === params.cityId})
    //       if (obj) {
    //         json.label += obj.RegionName
    //       }
    //       chineseSearchList.push(json)
    //     }
    //     if (params.districtId) {
    //       json = {
    //         label: '区县:',
    //         value: 'districtId'
    //       }
    //       obj = this.districtData.find((e) => { return e.RegionId === params.districtId})
    //       if (obj) {
    //         json.label += obj.RegionName
    //       }
    //       chineseSearchList.push(json)
    //     }
    //     if (params.SubParkId) {
    //       json = {
    //         label: '开发区:',
    //         value: 'SubParkId'
    //       }
    //       obj = this.subParkData.find((e) => { return e.BaseHighteckParkId === params.SubParkId})
    //       if (obj) {
    //         json.label += obj.ParkName
    //       }
    //       chineseSearchList.push(json)
    //     }
    //     if (params.timeLength) {
    //       json = {
    //         label: '融资时间:',
    //         value: 'timeLength'
    //       }
    //       obj = this.refinanceDateData.find((e) => { return e.RegionId === params.timeLength})
    //       if (obj) {
    //         json.label += obj.RegionName
    //       }
    //       chineseSearchList.push(json)
    //     }

    //     if (params.selfTime) {
    //       let json = {
    //         label: '融资时间:自定义时间',
    //         value: 'SubParkId'
    //       }
    //       chineseSearchList.push(json)
    //     }

    //     if (params.primaryIndustryId) {
    //       json = {
    //         label: '一级行业:',
    //         value: 'primaryIndustryId'
    //       }
    //       obj = this.industryData.find((e) => { return e.BaseIndustryId === params.primaryIndustryId})
    //       if (obj) {
    //         json.label += obj.Industry
    //       }
    //       chineseSearchList.push(json)
    //     }

    //     if (params.subIndustryId) {
    //       json = {
    //         label: '二级行业:',
    //         value: 'subIndustryId'
    //       }
    //       obj = this.secIndustryData.find((e) => { return e.BaseIndustryId === params.subIndustryId})
    //       if (obj) {
    //         json.label += obj.Industry
    //       }
    //       chineseSearchList.push(json)
    //     }

    //     if (params.refinanceRoundId && params.refinanceRoundId.length) {
    //       json = {
    //         label: '融资轮次:',
    //         value: 'refinanceRoundId'
    //       }
    //       let arr = []
    //       this.refinanceRoundData.forEach(e=>{
    //         if (params.refinanceRoundId.includes(e.BaseInfoId)){
    //           arr.push(e.Value)
    //         }
    //       })
    //       if (arr.length) {
    //         json.label += arr.join(',')
    //       }
    //       chineseSearchList.push(json)
    //     }

    //     if (params.IndustrialParkId) {
    //       json = {
    //         label: '产业园区:',
    //         value: 'IndustrialParkId'
    //       }
    //       obj = this.IndusParkList.find((e) => { return e.BaseIndustrialParkId === params.IndustrialParkId})
    //       if (obj) {
    //         json.label += obj.IndustrialParkName
    //       }
    //       chineseSearchList.push(json)
    //     }
    //     if (params.QualificationTag) {
    //       json = {
    //         label: '资质标签:'+params.QualificationTag,
    //         value: 'QualificationTag'
    //       }
    //       chineseSearchList.push(json)
    //     }
    //     return chineseSearchList
    // }
  },
  // watch: {
  //   exportParam: {
  //     deep: true,
  //     handler(newData,oldData) {
  //       this.getSearchChinese(newData)
  //     }
  //   }
  // },
  mounted() {
    this.userMessage = localStorage.getItem('userInfo')?JSON.parse(localStorage.getItem('userInfo')):{};
    this.getProvince()
    this.getRound()
    this.getIndustry()
    this.getIndusPark()
    this.getIndustryTag()
    this.getQua()
    document.onkeydown = (ev) => {
        var event = ev || event
        if(event.keyCode==13){
            this.searchQuery()
        }
    }
    // const parent = window.parent;
    // if(!parent) rturn
    // setInterval( () => {
    //   let height = 0
      
    //   let dom = document.getElementsByClassName('webCard')
    //   if (!dom) return
    //   console.log('dom', dom)
    //   height = dom[0].clientHeight
    //   parent.postMessage({ height: height }, '*')
    // }, 800)
    
  },
  beforeDestroy(){
    document.onkeydown = null
  },
    methods: {
      cancelSelect(key){
        if (key === 'refinanceRoundId') {
          this.exportParam[key] = []
        } else if (key === 'timeLength' || key === 'selfTime') {
          this.exportParam[key] = null
        } else {
          this.exportParam[key] = ''
        }
        this.$forceUpdate()
      },
      getSearchChinese(params) {
        this.chineseSearchList = []
        console.log('aaaa', params)
        let obj = null
        let json = {}
        if (params.provinceId) {
          json = {
            label: '省份:',
            value: 'provinceId'
          }
          obj = this.provinceData.find((e) => { return e.RegionId === params.provinceId})
          if (obj) {
            json.label += obj.RegionName
          }
          this.chineseSearchList.push(json)
        }
        if (params.cityId) {
          json = {
            label: '城市:',
            value: 'cityId'
          }
          obj = this.cityData.find((e) => { return e.RegionId === params.cityId})
          if (obj) {
            json.label += obj.RegionName
          }
          this.chineseSearchList.push(json)
        }
        if (params.districtId) {
          json = {
            label: '区县:',
            value: 'districtId'
          }
          obj = this.districtData.find((e) => { return e.RegionId === params.districtId})
          if (obj) {
            json.label += obj.RegionName
          }
          this.chineseSearchList.push(json)
        }
        if (params.SubParkId) {
          json = {
            label: '开发区:',
            value: 'SubParkId'
          }
          obj = this.subParkData.find((e) => { return e.BaseHighteckParkId === params.SubParkId})
          if (obj) {
            json.label += obj.ParkName
          }
          this.chineseSearchList.push(json)
        }
        if (params.timeLength) {
          json = {
            label: '融资时间:',
            value: 'timeLength'
          }
          obj = this.refinanceDateData.find((e) => { return e.RegionId === params.timeLength})
          if (obj) {
            json.label += obj.RegionName
          }
          this.chineseSearchList.push(json)
        }

        if (params.selfTime) {
          let json = {
            label: '融资时间:自定义时间',
            value: 'SubParkId'
          }
          this.chineseSearchList.push(json)
        }

        if (params.primaryIndustryId) {
          json = {
            label: '一级行业:',
            value: 'primaryIndustryId'
          }
          obj = this.industryData.find((e) => { return e.BaseIndustryId === params.primaryIndustryId})
          if (obj) {
            json.label += obj.Industry
          }
          this.chineseSearchList.push(json)
        }

        if (params.subIndustryId) {
          json = {
            label: '二级行业:',
            value: 'subIndustryId'
          }
          obj = this.secIndustryData.find((e) => { return e.BaseIndustryId === params.subIndustryId})
          if (obj) {
            json.label += obj.Industry
          }
          this.chineseSearchList.push(json)
        }

        if (params.refinanceRoundId && params.refinanceRoundId.length) {
          json = {
            label: '融资轮次:',
            value: 'refinanceRoundId'
          }
          let arr = []
          this.refinanceRoundData.forEach(e=>{
            if (params.refinanceRoundId.includes(e.BaseInfoId)){
              arr.push(e.Value)
            }
          })
          if (arr.length) {
            json.label += arr.join(',')
          }
          this.chineseSearchList.push(json)
        }

        if (params.IndustrialParkId) {
          json = {
            label: '产业园区:',
            value: 'IndustrialParkId'
          }
          obj = this.IndusParkList.find((e) => { return e.BaseIndustrialParkId === params.IndustrialParkId})
          if (obj) {
            json.label += obj.IndustrialParkName
          }
          this.chineseSearchList.push(json)
        }
        if (params.QualificationTag) {
          json = {
            label: '资质标签:'+params.QualificationTag,
            value: 'QualificationTag'
          }
          this.chineseSearchList.push(json)
        }
        this.$forceUpdate()
      },
      // setParams(params) {
      //   // this.queryParam = {}
      //   this.queryParam = JSON.parse(JSON.stringify(params))
      // },
      searchResetSelf(){
        this.queryParam = {}
        this.exportParam = {}
        this.areaType = 'province'
        this.loadData()
        this.$forceUpdate()
      },
      handleToCompany(data){
        this.showCompanyDetail = true
        this.companyId = data.Company
      },
      getIndustryTag(){
        this.$http.postAction('/baseIndustryTag/queryRows',{pageNo:1,pageSize:9999}).then((res)=>{
          if(res.status == 1){
            this.industryTagData = res.data.rows;
          }
        })
      },
      getIndusPark(){
        this.IndusParkList = []
        this.$http.postAction("/baseIndustrialPark/queryRows",{pageIndex:1,pageSize:9999,selectFields:[]}).then(res=>{
          if(res.status == 1){
            this.IndusParkList = res.data.rows;
          }
        })
      },
      handleImportExcelPy(){
        this.$message.success('正在获取数据，请稍等');
        axios.get('http://localhost:8901/ai/company/getRefinaceExcel?fileName=url.xlsx').then(res=> {
          if(res && res.data && res.data.message){
            this.modalData = res.data.message
            this.showModal = true
          } else {
             this.$message.success('拉取失败，请联系管理员');
          }
        }).catch(res=>{
          this.$message.success('本机未安装服务');
        })
      },
      moment,
      getIndustry(){
        this.$http.postAction('/baseIndustry/queryRows',{pageNo:1,pageSize:9999,orders:[{field:'OrderNum',desc:false}],selectFields:[],conditions:[{
              "field":"UpIndustry.Industry",
              "operator":"IS NULL",
              "value":""
            }]}).then((res)=>{
          if(res.status == 1){
            this.industryData = res.data.rows;
          }
        })
      },
      setQuality(tag){
        this.exportParam.QualificationTag = tag
        this.$forceUpdate()
        this.getSearchChinese(this.exportParam)
      },
      setPrimaryIndustry(id){
        this.exportParam.primaryIndustryId = id
        this.getErjiIndustry()
      },
      setSubPark(id){
        this.exportParam.SubParkId = id
        this.$forceUpdate()
        this.getSearchChinese(this.exportParam)
      },
      getErjiIndustry(){
        this.exportParam.subIndustryId = ''
        this.exportParam.thirdIndustryId = ''
        this.secIndustryData = []
        this.thirdIndustryData = []
        if (!this.exportParam.primaryIndustryId) {
          return
        }
        this.$http.postAction('/baseIndustry/queryRows',{pageNo:1,pageSize:9999,selectFields:[],orders:[{field:'OrderNum',desc:false}],conditions:[{
            "field":"UpIndustry",
            "operator":"=",
            "value":this.exportParam.primaryIndustryId
          }]}).then((res)=>{
          if(res.status == 1){
            this.secIndustryData = res.data.rows;
          }
        })
      },
      setSubIndustry(id){
        this.exportParam.subIndustryId = id
        this.getThirdIndustry()
      },
      getThirdIndustry(){
        if (!this.exportParam.subIndustryId) {
          this.exportParam.thirdIndustryId = ''
          this.thirdIndustryData = []
          return
        }
        this.$http.postAction('/baseIndustry/queryRows',{pageNo:1,pageSize:9999,orders:[{field:'OrderNum',desc:false}],selectFields:[],conditions:[{
            "field":"UpIndustry",
            "operator":"=",
            "value":this.exportParam.subIndustryId
          }]}).then((res)=>{
          if(res.status == 1){
            this.thirdIndustryData = res.data.rows;
          }
        })
      },
      setThirdIndustry(id){
        this.exportParam.thirdIndustryId = id
      },
      getQua(){
        this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'QualificationTag'
            }]}).then((res)=>{
          if(res.status == 1){
            this.qualificationTagData = res.data.rows;
          }
        })
      },
      getRound() {
        this.$http.postAction(this.url.baseList,{pageIndex:1,pageSize:100,selectFields:[],orders:[{field:'OrderNum',desc:false}],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'RefinanceRound'
            }]}).then((res)=>{
          if(res.status == 1){
            this.refinanceRoundData = res.data.rows;
            this.refinanceRoundData = this.refinanceRoundData.filter(e => {
              return e.Value !== '退市' && e.Value !== '不明确'
            })
          }
        })
      },
      setRoundClear(){
        this.exportParam.refinanceRoundId = []
        this.$forceUpdate()
      },
      setRound(id){
        if (!this.exportParam.refinanceRoundId){
          this.exportParam.refinanceRoundId = [id]
          return
        }
        if (!this.exportParam.refinanceRoundId.includes(id)){
          this.exportParam.refinanceRoundId.push(id)
        } else {
          this.exportParam.refinanceRoundId = this.exportParam.refinanceRoundId.filter(e => {
            return e !== id
          })
        }
        this.$forceUpdate()
        // this.exportParam.refinanceRoundId = id
      },
      getProvince(){
        this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"RegionType",
              "operator":"=",
              "value":1
            }]}).then(res=>{
          if(res.status == 1){
            this.provinceData = res.data.rows;
          }
        })
      },
      getSubPark(){
        this.subParkData = []
        if (!this.exportParam.provinceId) {
          return
        }
        this.$http.postAction("/baseHighteckPark/queryRows",{pageIndex:1,pageSize:9999,conditions:[{
            "field":"Region",
            "operator":"=",
            "value":this.exportParam.provinceId
          }]}).then(res=>{
          if(res.status == 1){
            this.subParkData = res.data.rows;
          }
        })
      },
      setProvince(id){
        this.areaType = 'city'
        this.exportParam.provinceId = id
        this.getCity()
        this.getSubPark()
        this.$forceUpdate()
      },
      setCity(id){
        this.areaType = 'district'
        this.exportParam.cityId = id
        this.getDistrict()
        this.$forceUpdate()
      },
      setDistrict(id){
        this.exportParam.districtId = id
        this.$forceUpdate()
      },
      setTimeLength(id){
        this.exportParam.selfTime = null
        this.exportParam.timeLength = id
        this.$forceUpdate()
      },
      setSelfTime(val){
        this.exportParam.selfTime = val
        this.exportParam.timeLength = ''
        this.$forceUpdate()
      },
      getCity(){
        this.exportParam.districtId = ''
        this.districtData = []
        this.exportParam.cityId = ''
        this.cityData = []
        if (!this.exportParam.provinceId) { 
          return
        }
        this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
            "field":"Parent",
            "operator":"=",
            "value":this.exportParam.provinceId
          }]}).then(res=>{
          if(res.status == 1){
            this.cityData = res.data.rows;
          }
        })
      },
      getDistrict() {
        if (!this.exportParam.cityId) {
          this.exportParam.districtId = ''
          this.districtData = []
          return
        }
        this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
            "field":"Parent",
            "operator":"=",
            "value":this.exportParam.cityId
          }]}).then(res=>{
          if(res.status == 1){
            this.districtData = res.data.rows;
          }
        })
      },
    }
  }
</script>
<style scoped>

  @import '~@assets/less/common.less';
  .configRow{
    /*height:500px;*/
    margin-bottom:10px;
  }
  .configRow >label{
    width: 80px;
    float: left;
    line-height: 30px;
    text-align: right;
    font-weight: 600;
  }
  .configRow .row-data{
    float: right;
    width: calc(100% - 80px);
    line-height: 30px;
  }
  .tag{
    color: #0e67b3;
    font-weight: 600
  }
  .blue{
    color: #1890ff;
    background: #e6f7ff;
    border-color: #91d5ff;
  }
  .default{
    background: transparent;
    border: none;
  }
  .specialBox{
    background: #fafafa;
    padding: 10px 20px;
    border-radius: 3px;
    margin-top: 5px;
    border: solid 1px #91d5ff;
  }
  /*/deep/ .ant-card .ant-card-body{
    max-height: 100% !important
  }*/
  /*/deep/ .ant-table-wrapper .ant-spin-nested-loading {
    height: 100%;
  }
  /deep/ .ant-table-wrapper .ant-spin-nested-loading .ant-spin-container{
    height: 100%;
  }
  /deep/ .ant-table-wrapper .ant-spin-nested-loading .ant-spin-container .ant-table{
    height: 100%
  }*/
</style>